Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline support #67

Closed
wants to merge 4 commits into from
Closed

Multiline support #67

wants to merge 4 commits into from

Conversation

robtfm
Copy link
Contributor

@robtfm robtfm commented Aug 9, 2024

adds multiline support, including cursor up/down and start/end document navigation, and a NewLine action for inserting linebreaks.

two annoyances:

  • when the cursor is in between the final char of one line and the first char of the next, it appears at the end of the line instead of the start of the following line. i considered adding some manual line break into the text-sections, but it's very messy. the alternative is to make the cursor a floating entity and not part of the text itself. this is pretty tricky while we can't properly determine the position of spaces (they have no PositionedGlyphs)
  • sections breaks are interpreted by ab_glyph as word boundaries, so if you have the cursor in the middle of a word which has wrapped from a line above, it gets broken at the cursor. floating cursor would fix this, but cosmic text also fixes it on main

@robtfm
Copy link
Contributor Author

robtfm commented Aug 9, 2024

it sounds like the first issue might be resolvable using a cursor char with a non-zero width and a negative right sidebearing to allow the next character to overlap it.

not sure if ab_glyph supports this, and not familiar enough with ttf to know how to set this up, but i will investigate

@rparrett
Copy link
Owner

rparrett commented Aug 9, 2024

Will take a closer look later tonight.

it sounds like the first issue might be resolvable using a cursor char with a non-zero width and a negative right sidebearing to allow the next character to overlap it.

Interesting. The zero-width cursor was relatively easy to set up in FontForge, so that seems worth testing I guess. But if we would need to swap between two special cursors that seems like a bit much.

this is pretty tricky while we can't properly determine the position of spaces (they have no PositionedGlyphs)
...
sections breaks are interpreted by ab_glyph as word boundaries, so if you have the cursor in the middle of a word which has wrapped from a line above, it gets broken at the cursor. floating cursor would fix this, but cosmic text also fixes it on main

I have thought about a solution involving inferring the width of spaces but even just putting that thought into text has me feeling a bit queasy.

I am probably okay with a bit of multi-line jank since the behavior is optional and can be fixed up when Bevy 0.15 lands.

@robtfm
Copy link
Contributor Author

robtfm commented Aug 9, 2024

there is some space management queasiness waiting for you in here already ... i use the width of the target glyph to adjust for spaces on line up/down, which will be a bit dodgy for non-mono fonts. using something like (next.position - current.position - current.size) / (num_whitespaces) would be better for that as well.

@robtfm
Copy link
Contributor Author

robtfm commented Aug 9, 2024

unfortunately i can't see how to set the bounding box separately from the sidebearing in birdfont or fontforge. it seems like it should be possible but i can't really justify any more time.

having looked into cosmic a bit more i agree that this pr and the other things i wanted will be much easier once that's released, so i think i will wait for now.

@rparrett
Copy link
Owner

so i think i will wait for now.

Do you mean that you are not inclined to get this merged, or just that you are okay with the current level of jank?

@robtfm
Copy link
Contributor Author

robtfm commented Aug 10, 2024

it's up to you for this one. i was mainly referring to the other things on my list (selection hilighting, copy/paste, mouse interactions).

most of the navigation implementation here should be possible to replace with much cleaner Buffer operations in 0.15, but it does kind of work as it is, and doesn't make single-line any worse.

@rparrett
Copy link
Owner

Played around with this a bit and also with trying to do a floating cursor. I think I would prefer to shelve this for now and wait for Bevy 0.15 for this feature.

I am also open to doing some work on a branch tracking bevy main.

@rparrett rparrett closed this Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants